-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
govet: implement analyzers config #697
Conversation
fc1260e
to
c656992
Compare
c656992
to
7de6ae1
Compare
I'm not sure why CI is failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! just a few comments
pkg/golinters/govet.go
Outdated
} | ||
for _, n := range cfg.Disable { | ||
if n == name { | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it should be
return true | |
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, nice catch!
I've also added a corresponding test for that function.
return false | ||
} | ||
|
||
func analyzersFromConfig(cfg *config.GovetSettings) []*analysis.Analyzer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, add minimal validation to (r *FileReader) validateConfig()
by calling something like:
func (cfg *config.GovetSettings) Validate() error {
if cfg.EnableAll && cfg.DisableAll {
return errors.New("enable-all and disable-all can't be combined")
}
if cfg.EnableAll && len(cfg.Enable) != 0) {
return errors.New("enable-all and enable can't be combined")
}
if cfg.DisableAll && len(cfg.Disable) != 0) {
return errors.New("disable-all and disable can't be combined")
}
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thank you.
We probably want to validate that cfg.Enable
contains valid analyzer names, but I'm not sure how to do it in that scope.
Fix #696, #446
Please feel free to request any changes.